﻿using LdCommunication.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls.WebParts;

namespace LD.Host.SECS
{
    public class PipeSocket:IDisposable
    {
        private string ip = "127.0.0.1";

        private int port = 5000;

        private Socket socket;

        private int connectTimeOut = 5000;

        private int receiveTimeOut = 5000;
        public PipeSocket()
        {

        }
        public PipeSocket(string ip,int port)
        {
            this.ip = ip;
            this.port = port;
        }

        public string IpAddress
        {
            get { return ip; }
            set { ip = value; }
        }
        public int Port
        {
            get { return port; }
            set { port = value; }
        }
        public int ConnectTimeOut
        {
            get
            {
                return connectTimeOut;
            }
            set
            {
                connectTimeOut = value;
            }
        }
        public int ReceiveTimeOut
        {
            get
            {
                return receiveTimeOut;
            }
            set
            {
                receiveTimeOut = value;
            }
        }
        public Socket Socket
        {
            get
            {
                return socket;
            }
            set
            {
                socket = value;
            }
        }
        public IPEndPoint GetConnectIPEndPoint()
        {
            return new IPEndPoint(IPAddress.Parse(IpAddress), Port);
        }
        public void Dispose()
        {
            socket?.Close();
        }
    }
}
